﻿/*
#**************************************************************************
#  openSIS is a student information system for public and non-public 
#  schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
#  openSIS is  web-based, open source, and comes packed with features that 
#  include student demographic info, scheduling, grade book, attendance, 
#  report cards, eligibility, transcripts, parent portal, 
#  student portal and more.   
#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send 
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License  
#  as  published by the Free Software Foundation, version 2 of the License. 
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************** 

*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using OSISStudentSetupDataLayer;
using OSISDynamicTranslation;

namespace OSISStudentSetupBusinessLayer
{
    public class StudentSetupBL
    {
        private string LanguageToolStSet;
        private string fieldname;
        private int previousorder;
        private int controltype;
        private int schoolid;
        private int studentid;
        private int stafftypeid;
        private int extrafieldid;
        private int sortorder;
        private string ddllistitemname;
        private int categoryid;
        private string categoryname;
        private string fieldstatus;
        private int fieldid;
        private string fieldview;
        private static string langto;

        public StudentSetupBL()
        {
            previousorder = 0;
            sortorder = 0;
            fieldname = "";
            controltype = 0;
            schoolid = 0;
            studentid = 0;
            stafftypeid = 0;
            extrafieldid = 0;
            ddllistitemname = "";
            categoryid = 0;
            categoryname = "";
            fieldstatus = "";
            fieldid = 0;
            fieldview = "";
            LanguageToolStSet = "";
        }

        public string LangTool
        {
            get
            {
                return this.LanguageToolStSet;
            }
            set
            {
                this.LanguageToolStSet = value;
            }
        }

        public String FieldView
        {
            get
            {
                return this.fieldview;
            }
            set
            {
                this.fieldview = value;

            }
        }
        public int FieldId
        {
            get
            {
                return this.fieldid;
            }
            set
            {
                this.fieldid = value;
            }
        }

        public int PreviousOrder
        {
            get
            {
                return this.previousorder;
            }
            set
            {
                this.previousorder = value;
            }
        }

        public String FieldStatus
        {
            get
            {
                return this.fieldstatus;
            }
            set
            {
                this.fieldstatus = value;

            }
        }
        public String CategoryName
        {
            get
            {
                return this.categoryname;
            }
            set
            {
                this.categoryname = value;

            }
        }
        public int CategoryId
        {
            get
            {
                return this.categoryid;
            }
            set
            {
                this.categoryid = value;
            }
        }
        public int SortOrder
        {
            get
            {
                return this.sortorder;
            }
            set
            {
                this.sortorder = value;
            }
        }
        public String FieldName
        {
            get
            {
                return this.fieldname;
            }
            set
            {
                this.fieldname = value;

            }
        }
        public int ControlType
        {
            get
            {
                return this.controltype;
            }
            set
            {
                this.controltype = value;

            }
        }
        public int SchoolId
        {
            get
            {
                return this.schoolid;
            }
            set
            {
                this.schoolid = value;
            }
        }
        public int StudentId
        {
            get
            {
                return this.studentid;
            }
            set
            {
                this.studentid = value;
            }
        }
        public int StaffTypeId
        {
            get
            {
                return this.stafftypeid;
            }
            set
            {
                this.stafftypeid = value;
            }
        }
        public int ExtraFieldId
        {
            get
            {
                return this.extrafieldid;
            }
            set
            {
                this.extrafieldid = value;
            }
        }

        public String DdlListitemName
        {
            get
            {
                return this.ddllistitemname;
            }
            set
            {
                this.ddllistitemname = value;

            }
        }

        public DataSet populateUserControls()
        {
            StudentSetupDL StSetUpDL = new StudentSetupDL();
            DataSet ds = null;
            ds = StSetUpDL.PopulateUserCtrls();       
            return ds;
        }

        public DataSet populateCategory()
        {
           StudentSetupDL stDl = new StudentSetupDL(); 
           DataSet ds = null;
           ds = stDl.PopulateCategory(this);
           DynamicTranslation DTL = new DynamicTranslation();
           
           if (LangTool != "en")
              {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        string origtext = ds.Tables[0].Rows[i]["Cat_Name"].ToString();
                        string trantext = DTL.Translate(origtext, "en", LangTool);
                        ds.Tables[0].Rows[i]["Cat_Name"] = trantext;
                    }
              }
           return ds;               
        }

        public System.Data.DataTable GetFieldsByCategory()
        {
            StudentSetupDL stdl = new StudentSetupDL();
            DynamicTranslation DTL = new DynamicTranslation();
            
            try
            {
                DataTable dt = stdl.getfieldsbycategory(this);
                if (LangTool != "en")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string origtext = dt.Rows[i]["FieldName"].ToString();
                        string trantext = DTL.Translate(origtext, "en", LangTool);
                        dt.Rows[i]["FieldName"] = trantext;
                    }
                }
                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }

        public int CheckDefaultAddressFieldCount()
        {
            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                int count = stdl.checkdefaultaddressfieldcount(this);
                return count;
            }
            catch
            {
                return 0;
            }
            finally
            {
                stdl = null;
            }
        }

        public System.Data.DataTable GetAddressFieldsByFieldId()
        {
            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                DataTable dt = stdl.getaddressfieldsbyfieldid(this);
                DynamicTranslation DTL = new DynamicTranslation();

                if (LangTool != "en")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string origtext = dt.Rows[i]["FieldName"].ToString();
                        string trantext = DTL.Translate(origtext, "en", LangTool);
                        dt.Rows[i]["FieldName"] = trantext;
                    }
                }
                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }

        public System.Data.DataTable GetSpecialEducation()
        {
            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                DataTable dt = stdl.GetSpecialEducation(this);
                DynamicTranslation DTL = new DynamicTranslation();

                if (LangTool != "en")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string origtext = dt.Rows[i]["FieldName"].ToString();
                        string trantext = DTL.Translate(origtext, "en", LangTool);
                        dt.Rows[i]["FieldName"] = trantext;
                    }
                }
                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }

        public System.Data.DataTable GetGiftedEducation()
        {
            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                DataTable dt = stdl.GetGiftedEducation(this);
                DynamicTranslation DTL = new DynamicTranslation();

                if (LangTool != "en")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string origtext = dt.Rows[i]["FieldName"].ToString();
                        string trantext = DTL.Translate(origtext, "en", LangTool);
                        dt.Rows[i]["FieldName"] = trantext;
                    }
                }
                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }

        public System.Data.DataTable GetAdditionalContact()
        {
            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                DataTable dt = stdl.GetAdditionalContact(this);
                DynamicTranslation DTL = new DynamicTranslation();

                if (LangTool != "en")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string origtext = dt.Rows[i]["FieldName"].ToString();
                        string trantext = DTL.Translate(origtext, "en", LangTool);
                        dt.Rows[i]["FieldName"] = trantext;
                    }
                }
                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }

        public void ControlAdd()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.controladd(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }

        public void AddDdlListItem()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.addddllistItem(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }

        public void getExtraFieldId()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                DataSet ds = stDl.GetExtraFieldId(this);
                extrafieldid = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }

        }


        public void deleteListItems()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.deletelistitems(this);
            }
            catch
            {
            }
            finally
            { stDl = null; }
        }

        public void deletecustomfield()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.DeleteCustomField(this);
            }
            catch
            {
            }
            finally
            { stDl = null; }
        }       

        public System.Data.DataTable populatecustomfield()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                DataTable dt = stdl.PopulatrCustomField(this);
                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }

      
        public void AddCategory()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.addcategory(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public System.Data.DataTable GetMaxCatergoryId()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                DataTable dt = stdl.getmaxcatergoryid(this);
                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }   
        
        public void UpdateDefaultFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updatedefaultfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }

        public void UpdateCustomFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updatecustomfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public int CheckDefaultFieldCount()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                int count = stdl.checkdefaultfieldcount(this);
                return count;
            }
            catch
            {
                return 0;
            }
            finally
            {
                stdl = null;
            }
        }
        public void InsertDefaultFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.insertdefaultfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }

        public int CheckSpecialFieldFromStatusTable()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                int count = stdl.CheckSpecialFieldFromStatusTable(this);
                return count;
            }
            catch
            {
                return 0;
            }
            finally
            {
                stdl = null;
            }
        }

        public void UpdateDefaultSpecialFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.UpdateDefaultSpecialFieldStatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }

        public void UpdateDefaultSpecialFieldView()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.UpdateDefaultSpecialFieldView(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void Insertspecialfieldstatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.insertspecialfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }

        public int CheckGiftedFieldFromStatusTable()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                int count = stdl.CheckGiftedFieldFromStatusTable(this);
                return count;
            }
            catch
            {
                return 0;
            }
            finally
            {
                stdl = null;
            }
        }

        public void UpdateDefaultGiftedFieldView()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.UpdateDefaultGiftedFieldView(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void UpdateDefaultgiftedFieldViewStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.UpdateDefaultgiftedFieldViewstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void Insertgiftedfieldstatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.insertgiftedfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }





        //newly added###########################################3
        //######################################################
       
       
     
      
        public int CheckAddressFieldFromStatusTable()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                int count = stdl.checkaddressfieldfromstatustable(this);
                return count;
            }
            catch
            {
                return 0;
            }
            finally
            {
                stdl = null;
            }
        }
        public void UpdateDefaultAddressFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updatedefaultaddressfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void InsertDefaultAddressFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.insertdefaultaddressfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public int CheckAdditionalContactList()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                int count = stdl.checkadditionalcontactlist(this);
                return count;
            }
            catch
            {
                return 0;
            }
            finally
            {
                stdl = null;
            }
        }
        public System.Data.DataTable GetAdditionalContactFields()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                DataTable dt = stdl.getadditionalcontactfields(this);

                DynamicTranslation DTL = new DynamicTranslation();
              //  langto = System.Web.HttpContext.Current.Session["MLUICulture"].ToString();
                

                   


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string origtext = dt.Rows[i]["FieldName"].ToString();

                    string trantext = DTL.Translate(origtext, "en", langto);
                    dt.Rows[i]["FieldName"] = trantext;


                }




                return dt;
            }
            catch
            {
                return null;
            }
            finally
            {
                stdl = null;
            }
        }
        public void UpdateAdditionalAddressFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updateadditionaladdressfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public int CheckAdditionalAddressFieldFromStatusTable()
        {

            StudentSetupDL stdl = new StudentSetupDL();
            try
            {
                int count = stdl.checkadditionaladdressfieldfromstatustable(this);
                return count;
            }
            catch
            {
                return 0;
            }
            finally
            {
                stdl = null;
            }
        }
        public void InsertAdditionalAddressFieldStatus()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.insertadditionaladdressfieldstatus(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void UpdateDefaultFieldView()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updatedefaultfieldview(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void UpdateCustomFieldView()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updatecustomfieldview(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void UpdateDefaultAddressFieldView()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updatedefaultaddressfieldview(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }
        public void UpdateAdditionalAddressFieldView()
        {
            StudentSetupDL stDl = new StudentSetupDL();
            try
            {
                stDl.updateadditionaladdressfieldview(this);
            }
            catch
            {
            }
            finally
            {
                stDl = null;
            }
        }

        public void UpdateCategoryAndOrder()
        {
            StudentSetupDL STDL = new StudentSetupDL();
            try
            {
                STDL.UpdateCategoryAndOrder(this);
            }
            catch
            {
            }
            finally
            {
                STDL = null;
            }
        }
     
    }
}
